package com.youku.component;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.youku.expression.environment.EnvironmentFactory;

/**
 * 测试用例组
 * 
 * @author loda
 *
 */
public class TestSuite extends BaseAttribute implements ProjectStep {

	private static final Logger logger = LoggerFactory.getLogger(TestSuite.class);

	private Project project;

	public TestSuite(Project project) {
		super();
		this.project = project;
	}

	public Project getProject() {
		return project;
	}

	public void setProject(Project project) {
		this.project = project;
	}

	public TestCase getCase(String caseId) {
		return (TestCase) getStepWithKey(caseId);
	}

	@Override
	public void run() {
		logger.info("===================testsuite==================>开始执行测试用例组{}", id);
		// 先清除局部作用域信息
		EnvironmentFactory.clearLocal(getProjectId());
		super.run();
		logger.info("<===================testsuite==================测试用例组{}测试完成", id);
	}

	@Override
	public void addVariable(String key, Object value) {
	}

	@Override
	public String getProjectId() {
		return project.getId();
	}

	@Override
	public String getCaseId() {
		return null;
	}

	@Override
	public String getSuiteId() {
		return id;
	}

	@Override
	public String getKey() {
		return id;
	}

}
